package flowers;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Solution {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		try {
			int N = in.nextInt(), K = in.nextInt();
			Integer C[] = new Integer[N];
			for(int i=0; i<N; i++)
				C[i] = in.nextInt();

			int result = 0;
			Arrays.sort(C, Collections.reverseOrder());
			for(int i = 0; i < N; i++)
				result += C[i] * (i / K + 1);
			System.out.println(result);
		} finally {
			in.close();
		}
	}
}
